package com.accenture.fd.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.accenture.fd.dao.Tb00008Dao;
import com.accenture.fd.entity.DesignScreenDto;
import com.accenture.fd.entity.Tb00008;
import com.accenture.fd.service.OutputDesignService;

@Service
public class OutputDesignServiceImpl implements OutputDesignService {

	@Autowired
	private Tb00008Dao tb00008Dao;

	@Override
	public List<String> getScreenIdList() {

		List<String> returnValue = new ArrayList<>();
		List<Tb00008> tb00008List = tb00008Dao.getScreenIdList();
		if (tb00008List != null && !tb00008List.isEmpty()) {

			for (int i = 0; i < tb00008List.size(); i++) {
				returnValue.add(tb00008List.get(i).getScreenId());
			}
		}

		return returnValue;
	}

	@Override
	public List<DesignScreenDto> getDesignScreenDtoList(String screenId, String filterValue) {

		List<DesignScreenDto> returnValue = new ArrayList<>();
		DesignScreenDto designScreenDto = null;
		List<Tb00008> tb00008List = tb00008Dao.getDesignScreenDtoList(screenId, filterValue);
		if (tb00008List != null && !tb00008List.isEmpty()) {

			//     		+ "design_type_id,"
			//     		+ "screen_id,"
			//     		+ "section,"
			//     		+ "screen_item_name,"
			//     		+ "screen_item_physics_name"
			//     		+ "type_cd,"
			//     		+ "attribute_cd"
			for (int i = 0; i < tb00008List.size(); i++) {
				designScreenDto = new DesignScreenDto();
				designScreenDto.setId(tb00008List.get(i).getSection());
				designScreenDto.setItemId(tb00008List.get(i).getScreenItemPhysicsName());
				designScreenDto.setItemName(tb00008List.get(i).getScreenItemName());
				designScreenDto.setItemType(tb00008List.get(i).getTypeCd());
				designScreenDto.setStructure(tb00008List.get(i).getAttributeCd());
				returnValue.add(designScreenDto);
			}
		}

		return returnValue;
	}

	@Override
	public List<DesignScreenDto> getDesignScreenDtoListTemporary(String screenId) {

		List<DesignScreenDto> returnValue = new ArrayList<>();
		DesignScreenDto designScreenDto = null;
		List<Tb00008> tb00008List = tb00008Dao.getDesignScreenDtoListTemporary(screenId);
		if (tb00008List != null && !tb00008List.isEmpty()) {

			//     		+ "design_type_id,"
			//     		+ "screen_id,"
			//     		+ "section,"
			//     		+ "screen_item_name,"
			//     		+ "screen_item_physics_name"
			//     		+ "type_cd,"
			//     		+ "attribute_cd"
			for (int i = 0; i < tb00008List.size(); i++) {
				designScreenDto = new DesignScreenDto();
				designScreenDto.setId(tb00008List.get(i).getSection());
				designScreenDto.setItemId(tb00008List.get(i).getScreenItemPhysicsName());
				designScreenDto.setItemName(tb00008List.get(i).getScreenItemName());
				designScreenDto.setItemType(tb00008List.get(i).getTypeCd());
				designScreenDto.setStructure(tb00008List.get(i).getAttributeCd());
				returnValue.add(designScreenDto);
			}
		}

		return returnValue;
	}
}
